﻿//Young's own code here　
var employeesJsonData;
var getLocalization = function () {
    var localizationobj = {};
    localizationobj.pagergotopagestring = "跳往页:";
    localizationobj.pagershowrowsstring = " 每页行:";
    localizationobj.pagerrangestring = " of ";
    localizationobj.pagernextbuttonstring = "下页";
    localizationobj.pagerpreviousbuttonstring = "上页";
    localizationobj.sortascendingstring = "升序";
    localizationobj.sortdescendingstring = "降序";
    localizationobj.sortremovestring = "不排序";

    return localizationobj;

};

//wait等待画面
function SetWait(parentElem, onOff) {
    if (onOff == true) {
        parentElem.append('<div id="waiting"><div><div><img alt="loading..." src="../Content/Images/waiting.gif")" /></div></div></div>');
        //$("#waiting").fadeIn().css("display", "table");
        $("#waiting", parentElem).css("display", "table");
    }
    else {
        $("#waiting", parentElem).fadeOut(1000);
        $("#waiting", parentElem).remove();
    }
}

//装载主菜单
function loadMenu(menuJsonObject, childContainer) {
    //'{"MenuNodes":{"MenuNode":[{"menuID":"1","menuName":"总查询","toolTip":"所有表查询"},{"menuID":"6","menuName":"关于...","toolTip":"关于软件"}]}}';
    if (menuJsonObject.MenuNode != null) {
        var ul1 = document.createElement("ul");
        if (childContainer.id == "menu_bar_menu") {
            ul1.setAttribute("id", "jqmainmenu");
            ul1.setAttribute("class", "sf-menu");

        }
        childContainer.appendChild(ul1);
        for (var menuNodeIndex in menuJsonObject.MenuNode) {
            var li1 = document.createElement("li");
            $(li1).attr("parentMenu", menuJsonObject.MenuNode[menuNodeIndex].parentMenu);
            $(li1).attr("tag", menuJsonObject.MenuNode[menuNodeIndex].tag);
            if (menuJsonObject.MenuNode[menuNodeIndex].MenuNode == null) {
                $(li1).attr("isFinal", true);
            }
            ul1.appendChild(li1);
            var a1 = document.createElement("a");
            a1.setAttribute("class", "hide");
            a1.setAttribute("href", "javascript:;");

            //a1.nodeType = 3;
            li1.appendChild(a1);
            var a1t = document.createTextNode(menuJsonObject.MenuNode[menuNodeIndex].menuName);
            a1.appendChild(a1t);
            loadMenu(menuJsonObject.MenuNode[menuNodeIndex], li1);
        }
    }

}

//处理主菜单
function handleMainmenuClick(ui) {
    if (ui.attr("isFinal") == "true") {
        jqmainmenu_handle.superfish('hide');
        var menuTag = ui.attr("tag");
        switch (menuTag) {
            case "employees":
                $("#contentFrame").attr("src", "Employees");
                break;
            case "departments":
                $("#contentFrame").attr("src", "Departments");
                break;
            case "unionquery":
                $("#contentFrame").attr("src", "Union");
                break;
            case "modifyemployee":
                $("#contentFrame").attr("src", "ModifyEmployee");
                break;
            case "modifydepartment":
                $("#contentFrame").attr("src", "ModifyDepartment");
                break;
            default:
        }

    }
}



